package com.keepers.repair.utils;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.AttrRes;


/**
 * Created by waitou on 17/1/18.
 */

public class ThemeUtils {

    private static final int[] TEMP_ARRAY = new int[1];

    public static int getThemeAttrId(Context context, @AttrRes int attr) {
        TEMP_ARRAY[0] = attr;
        TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY);
        try {
            return a.getResourceId(0, 0);
        } finally {
            a.recycle();
        }
    }

    public static int getThemeAttrColor(Context context, int attr) {
        TEMP_ARRAY[0] = attr;
        TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY);
        try {
            return a.getColor(0, 0);
        } finally {
            a.recycle();
        }
    }

}
